/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.util.HashMap;
import java.util.Map;
import libCore.Util;
import share.ShareMacros;

/**
 *
 * @author LinhTA
 */
public class Egg implements EntityBase{
    
    public String kind;
    public int gold;
    public long timeBirth;
    
    @Override 
    public Map<String,Object> toAMF()
    {
        Map<String,Object> data = new HashMap<String, Object>();
        
        data.put(ShareMacros.KIND, kind);
        data.put(ShareMacros.GOLD, gold);
        data.put(ShareMacros.EGGS_TIMESPAWN, timeBirth);
        
        return data;
    }
    
    @Override 
    public void setData(Map<String, Object> obj)
    {
        Map<String,Object> data = Util.obj2Map(obj);

        kind =data.get(ShareMacros.KIND).toString();
        gold = Integer.parseInt(data.get(ShareMacros.GOLD).toString());
        timeBirth = Long.parseLong(data.get(ShareMacros.EGGS_TIMEBIRTH).toString());
    }
    
//    public static class EggData{
//    public int type;
//    public long time;
//    public String id;
//    
//    public HashMap<String,Object> toObj()
//    {
//        HashMap<String,Object> data  = new HashMap<String, Object>();
//        
//        data.put("time", time);
//        data.put("type", type);
//        data.put("id", id);
//        
//        return data;
//    }
//    
//    }
}
